<script lang="ts">
  import {Component, Vue} from 'vue-property-decorator';

  @Component
  export default class Page extends Vue {
    public created() {
      const agentId = this.$route.params.agentId;
      const origin = location.origin;
      const redirectUri = `${origin}/ControlPanel/Oauth/WorkWeixin/${agentId}/LoginCallback`;
      const corpId = process.env.VUE_APP_WORK_WEIXIN_CORPID;
      if (corpId) {
        location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=#wechat_redirect`;
      } else {
        this.$message.error('企业ID无效');
      }
    }
  }
</script>
